/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var ajax = new sack();
var loc = document.location.toString();
var link = loc.substring(0, loc.lastIndexOf('/')) +'/';
var u;
var idf;
var version = null;

function getRezultat(file, owner, filename, version, fileid)
{
    ajax.requestFile = link + file + '?param1=' + owner + '&param2=' + filename + '&param3=' + version +'&param4=' + fileid;
    ajax.onCompletion = resultRezultat;
    ajax.runAJAX();
    u=username;
    idf=fileid
}

function restoreVers() {
    if (version != null)
        sendRestoreVers(version);
}

function resultRezultat()
{
    var response = eval('(' + ajax.response + ')');
    var textareaRev = document.getElementById("food");
    version = response.p3;
    if (textareaRev != null) {
        textareaRev.value = response.p1;
        document.getElementById("revisionHeader").innerHTML = "Version " + response.p3;
        return;
    }

    var d=document.getElementById("revisionArea");
    d.innerHTML+="<h3 id='revisionHeader'>Version " + response.p3 + "</h3>";
    d.innerHTML+='<br><input type="button" onClick="restoreVers()" value="Restore version">';
    d.innerHTML+="<p><textarea id='food' readonly='readonly' spellcheck='false' width='500' cols='50' rows='20'>"+response.p1+"</textarea></p>";
}

